//业务类
//将网络访问类中的get post方法导入
import {get, post} from './http'
import axios from "axios";

/******************************歌手操作***********************************/
//查询所有歌手
export const getAllSinger = () => get(`singer/allSinger`);
//根据性别查询歌手
export const getSingerOfSex = (sex) => get(`singer/singerOfSex?sex=${sex}`);

/******************************歌曲操作***********************************/
//根据歌手id查询歌曲
export const songOfSingerId = (id) => get(`song/singer/detail?singerId=${id}`);
//根据歌曲id查询歌曲对象
export const songOfSongId = (id) => get(`song/detail?songId=${id}`);
//根据歌手姓名（歌曲名 60号-《傻屌之歌》）模糊查询歌曲
export const likeSongOfName = (keywords) => get(`song/likeSongOfName?songName=${keywords}`);
//下载音乐
export const download = (url) => axios({
    method: 'get',
    url: url,
    responseType: 'blob'
});

/******************************歌单操作***********************************/
//查询所有歌单
export const getAllSongList = () => get(`songList/allSongList`);
//根据标题模糊查询歌单
export const getSongListOfLikeTitle = (keywords) => get(`songList/likeTitle?title=${keywords}`);
//根据歌手名字模糊查询歌单列表
export const getSongListLikeStyle = (style) => get(`songList/likeStyle?style=${style}`);

/******************************歌单歌曲操作***********************************/
//根据歌单id查询歌曲列表
export const listSongDetail = (songListId) => get(`listSong/detail?songListId=${songListId}`);

/******************************用户操作***********************************/
//查询所有用户
export const getAllConsumer = () => get(`consumer/allConsumer`);
//注册
export const SingUp = (params) => post(`consumer/add`, params);
//登录
export const LoginIn = (params) => post(`consumer/login`, params);
//根据用户id查询改用户的详细信息
export const getUserOfId = (id) => get(`consumer/selectByPrimaryKey?id=${id}`);
//更新用户信息
export const updateUserMsg = (params) => post(`consumer/update`, params);

/******************************评价操作***********************************/
//提交评分
export const setRank = (params) => post(`rank/add`, params);
//获取指定歌单的平均分
export const getRankOfSongListId = (songListId) => get(`rank?songListId=${songListId}`);
export const getRankByConsumer = (params) => get(`rank/isRank`, params);

/******************************评论操作***********************************/
//添加评论
export const setComment = (params) => post(`comment/add`, params);
//点赞
export const setLike = (params) => post(`comment/like`, params);
//返回当前歌单或歌曲的评论列表
export const getAllComment = (type, id) => {
    //歌曲
    if(type == 0){
        return get(`comment/commentOfSongId?songId=${id}`);
    }
    //歌单
    if(type == 1){
        return get(`comment/commentOfSongListId?songListId=${id}`);
    }
};

/******************************收藏操作***********************************/
//添加收藏
export const setCollect = (params) => post(`collect/add`, params);
//指定用户的收藏列表
export const getCollectOfUserId = (userId) => get(`collect/collectOfUserId?userId=${userId}`);
